package com.monkeyboy.second.threadpool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @Description
 * @Author Gavin
 * @date 2020.04.27 17:39
 */
public class ScheduledThreadPoolTest {
    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(10);
        //5秒钟后执行该任务
       // scheduledExecutorService.schedule(new com.monkey.thread.Task(), 5, TimeUnit.SECONDS);
        //每隔3秒钟执行一次该任务
        scheduledExecutorService.scheduleAtFixedRate(new Task(),1,3,TimeUnit.SECONDS);
    }
}
